<!-- 分页宏 -->
{% macro render_pagination(pagination, haha) %}
  <nav class='nav-pagination' aria-label='Page navigation' align='center'>
    <ul class='pagination'>
      <li {% if not pagination.has_prev %}class='disabled'{% endif %}>
        <a href="{{ url_for(haha, page=pagination.prev_num) if pagination.has_prev else '#' }}">&laquo;</a>
      </li>
      {% for page in pagination.iter_pages(left_edge=1, left_current=2, right_current=2, right_edge=1) %}
        {% if page %}
          {% if page != pagination.page %}
            <li><a href="{{ url_for(haha, page=page) }}">{{ page }}</a></li>
          {% else %}
            <li class='active'><a href='#'>{{ page }}
                <span class='sr-only'>(current)</span></a></li>
          {% endif %}
        {% else %}
          <li><span class='ellipsis'>...</span></li>
        {% endif %}
      {% endfor %}
      <li {% if not pagination.has_next %}class='disabled'{% endif %}>
        <a href="{{ url_for(haha, page=pagination.next_num) if pagination.has_next else '#' }}">&raquo;</a>
      </li>
    </ul>
  </nav>
{% endmacro %}



<!-- 博客页面评论专用分页宏 -->
{% macro render_pagination_comments(pagination, haha, id) %}
  <nav class='nav-pagination' aria-label='Page navigation' align='center'>
    <ul class='pagination'>
      <li {% if not pagination.has_prev %}class='disabled'{% endif %}>
        <a href="{{ url_for(haha, id=id, page=pagination.prev_num) if pagination.has_prev else '#' }}">&laquo;</a>
      </li>
      {% for page in pagination.iter_pages(left_edge=1, left_current=2, right_current=2, right_edge=1) %}
        {% if page %}
          {% if page != pagination.page %}
              <li><a href="{{ url_for(haha, id=id, page=page) }}">{{ page }}</a></li>
          {% else %}
            <li class='active'><a href='#'>{{ page }}
                <span class='sr-only'>(current)</span></a></li>
          {% endif %}
        {% else %}
          <li><span class='ellipsis'>...</span></li>
        {% endif %}
      {% endfor %}
      <li {% if not pagination.has_next %}class='disabled'{% endif %}>
        <a href="{{ url_for(haha, id=id, page=pagination.next_num) if pagination.has_next else '#' }}">&raquo;</a>
      </li>
    </ul>
  </nav>
{% endmacro %}
